//字酷云

$(document).ready(function(){
var ffamilyzky={
             'jian':{name:'简体',cell:{
			                    'jkaishu':{name:"楷书"},
			                    'jxinshu':{name:"行书"},
								'jcaoshu':{name:"草书"},
								'jlishu':{name:"隶书"},
								'jzhuanshu':{name:"篆书"},
							    'jjinwen':{name:"金文"},
								'jhuangcao':{name:"黄草"},
								'jshufajia':{name:"书法家"},
								'jweishu':{name:"魏书"},
								'jyishuti':{name:"艺术体"},
								'jsongshu':{name:"宋书"},
								'jkangshu':{name:"康书"},
								'jyaoshu':{name:"姚书"},
								'jshuti':{name:"舒体"}					
			 }
			 },
			 'fan':{name:'繁体',cell: {
			                      'fkaiti':{name:"楷体"},
								  'fxinshu':{name:"行体"},
								'fcaoshu':{name:"草书"},
								'flishu':{name:"隶书"},
								'fzhuanshu':{name:"篆书"},
							    'fjinwen':{name:"金文"},
								'fhuangcao':{name:"黄草"},
								'fshufajia':{name:"书法家"},
								'fweishu':{name:"魏书"},
								'fyishuti':{name:"艺术体"},
								'fsongshu':{name:"宋书"},
								'fkangshu':{name:"康书"},
								'fyaoshu':{name:"姚书"},
								'fshuti':{name:"舒体"}
								  
			 }}
			 
               };

   var zkyfsize = {
             "15px" : { name:"15px"},
			 "20px" : { name:"20px"},
			 "25px" : { name:"25px"},
            "30px"  : { name:"30px"},
	        "40px"  : { name:"40px"}
               };
 var zkybjfg = {
             "BC221C|DCF2F4" : { name:"默认"},
			 "000000|FFFFFF" : { name:"黑白"},
			 "222222|E4CA95" : { name:"禅趣"},
            "FF6699|FFFFFF"  : { name:"温馨"},
	        "669999|FFFFCC"  : { name:"柔和"},
			"52A300|FFD83D"  : { name:"校园"},
			"003366|00CCCC"  : { name:"雨后"},
			"333333|DDDDDD"  : { name:"素雅"},
			"D60000|FFFF47"  : { name:"明快"},
			"754900|FFEED0"  : { name:"随和"},
			"005B39|DFFFF3"  : { name:"清爽"},
			"A347FF|FFCCFF"  : { name:"轻盈"},
		    "00637B|CEF3FF"  : { name:"冬季"}
               };
var zkykplx = {
             "qm" : { name:"签名",width:"400px",height:"100px"},
             "mp" : { name:"名片",width:"501px",height:"301px"},
			 "kp" : { name:"卡片"},
			 "gs" : { name:"故事"},
            "ts"  : { name:"唐诗"},
	        "sc"  : { name:"宋词"},
			"yq"  : { name:"元曲"},
			"xs"  : { name:"小说"},
			"ym"  : { name:"幽默"},
			"cy"  : { name:"成语"},
			"my"  : { name:"名言"},
			"dl"  : { name:"对联"},
			"gc"  : { name:"歌词"},
		    "jj"  : { name:"警句"}
               };
			 

var opts = { data:ffamilyzky,
            ajax: url+"/getff",
			select: '#zkyffamily',
			head: "个性字体"
                    };
var opts1 = {data:zkyfsize,
			select: '#zkyfsize',
			head: "字体大小"
                    };

var opts2 = {data:zkybjfg,
			select: '#zkybjfg',
			head: "背景风格"
                    };	 
var opts3 = {data:zkykplx,
			select: '#zkykplx',
			head: "卡片类型"
                    };	

var linkageSelzkyffamily = new LinkageSel(opts);

var linkageSelzkybjfg = new LinkageSel(opts2);
var linkageSelzkykplx = new LinkageSel(opts3);
linkageSelzkybjfg.onChange(function() {
		//var v = linkageSelzkybjfg.getSelectedValue();  
		//var strs= new Array(); //定义一数组		
		//strs=v.split("|");
		
		  
						});

linkageSelzkykplx.onChange(function() {
          $('#zky-tta').css('width',linkageSelzkykplx.getSelectedData("width"));
		   $('#zky-tta').css('height',linkageSelzkykplx.getSelectedData("height"));		
		
						});

linkageSelzkyffamily.onChange(function() {
		var v = linkageSelzkyffamily.getSelectedArr();
	var strs= new Array(); //定义一数组		
	if (v[2]!="")
		  {
		   strs=v[2].split("|");
		    font=strs[1];
		//   $("#zky-tta").css("font-family",strs[1]);
		  
	    //   $.include(pub+"/css/"+strs[0]+"/"+strs[1]+".css" );  
		   //$("#zkyst").attr("href",pub+"/css/"+v[0]+"/"+v[1]+".css");
		   fontdir=strs[0];
		   }
		   
						});


var linkageSelzkyfsize = new LinkageSel(opts1);
linkageSelzkyfsize.onChange(function() {
		var v = linkageSelzkyfsize.getSelectedValue();  
		   $("#zky-tta").css("font-size",v);
						});

	 
$("#tti").bind("click",function()
             {			 
	        var ws = $('#zky-tta').attr('value');
			var userStyle= linkageSelzkybjfg.getSelectedValue(); 
			var haveBrLinker=$('#haveBrLinker:checked').attr('value');
			var w=$('#zky-tta').css('width');
			var h=$('#zky-tta').css('height');
			var fsize=$('#zky-tta').css('font-size');
			var ffamily=$('#zky-tta').css('font-family');
	
              $.ajax({
			type:"POST",
			url:url+"/texttoimg",
		    data:{word:ws, userStyle:userStyle,haveBrLinker:haveBrLinker,w:w,h:h,fsize:fsize,ffamily:ffamily,fontdir:fontdir},
			dataType:"json",
			error:function (XMLHttpRequest, textStatus, errorThrown) {alert('请求错误...'+errorThrown);},
			success:function(data){ 
			
				  $('#zky-tta').css('display','none');
				  $('#imgv').attr('src',ro+'/'+data.data);
				  $('#imgv').css('display','block');
				  
			        }
		              });

              });

						  
		
                
 
	
});

